﻿using Ewell.BizComponent.UI.Charge.ViewModel;
using Ewell.BizComponent.UI.Core.Model;
using MahApps.Metro.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace Ewell.BizComponent.UI.Charge.Windows
{
    /// <summary>
    /// ChargeWindow.xaml 的交互逻辑
    /// </summary>
    public partial class ChargeWindow : MetroWindow
    {
        private ChargeVm _chargeVm;
        public ChargeVm chargeVm
        {
            get => _chargeVm;
            set
            {
                if (_chargeVm != value)
                {
                    _chargeVm = value;
                    OnPropertyChanged(nameof(chargeVm));
                }
            }
        }
        public ChargeWindow()
        {
            InitializeComponent();
            DataContext = this;
        }

        private void MetroWindow_Loaded(object sender, RoutedEventArgs e)
        {
            if(chargeVm == null)
                chargeVm = new ChargeVm();
            chargeVm.localWindow = this;
            if (chargeVm.patientVm != null)
            {
                if(chargeVm.preSettlementVm!=null)
                    chargeVm.preSettlementVm.patient = chargeVm.patientVm;
                if(chargeVm.settlementVm!=null)
                    chargeVm.settlementVm.patient= chargeVm.patientVm;
            }
        }
    }
}
